#include "DeclareFile.h"
//#include "variable.h"
#include <graphics.h>
/*

移动素材(人物，吸血鬼)
移动速度(人物，吸血鬼)
死亡素材(人物，吸血鬼)
背景(游戏界面)
武器
血量
界面窗口大小
音乐





*/

bool MENU_SET;
bool GAME_PAUSE_SET;
IMAGE RankImg;
IMAGE SetImg;
IMAGE SoundOnImg;
IMAGE SoundOffImg;
IMAGE BgImg;
IMAGE DownAttackImg;
IMAGE UpAttackImg;
IMAGE LeftAttackImg;
IMAGE RightAttackImg;
IMAGE UpImg;
IMAGE DownImg;
IMAGE LeftImg;
IMAGE RightImg;
IMAGE MonsterUpImg;
IMAGE MonsterDownImg;
IMAGE MonsterRightImg;
IMAGE MonsterLeftImg;
int ranking[10000];
int PersonIndex;
int MusicSizeNumber;
int blood;
int flag;
int score;
int imgX;
int imgY;
int BUTTON_X;
int BUTTON_Y_1;
int BUTTON_Y_2;
int BUTTON_Y_3;
int BUTTON_WIDTH;
int BUTTON_HEIGHT;
int BUTTON_SPACING;
int HeroShowIndex;
int ControlValOne;
int ControlAttack1;
int ControlAttack2;
int ControlAttack3;
int ControlAttack4;
int FlushMillisecond;
int rx1;
int ry1;
int rx_w1;
int ry_h1;
int rx2;
int ry2;
int rx_w2;
int ry_h2;
int x_;
int y_;
int w;
int h;
int hSpace;
int vSpace;
int num_ranking;
ExMessage ms;
COLORREF BUTTON_COLOR;
COLORREF TEXT_COLOR;
IMAGE TitleImg;



void Init() {

	// 初始化图形窗口，大小为 800 * 600
	initgraph(800, 600);
	cleardevice();

	HeroShowIndex = 8;


	//初始化音乐大小
	MusicSizeNumber = 25;

	//初始化血量
	blood = 100;

	//初始化flag的值
	flag = 1;

	//初始化游戏分数
	score = 0;

	
	//加载人物下侧攻击素材
	loadimage(&DownAttackImg, "../Hero/DownAttackImg.png");


	//记载人物上侧攻击素材
	loadimage(&UpAttackImg, "../Hero/UpAttackImg.png");


	//加载人物左侧攻击素材
	loadimage(&LeftAttackImg, "../Hero/LeftAttackImg.png");



	//加载人物右侧攻击素材
	loadimage(&RightAttackImg, "../Hero/RightAttackImg.png");



	//加载人物向上移动素材
	loadimage(&UpImg, "../Hero/UpMove.png");


	//加载人物向下移动素材
	loadimage(&DownImg, "../Hero/DownMove.png");


	//加载人物向左移动素材
	loadimage(&LeftImg, "../Hero/LeftMove.png");


	//加载人物向右移动素材
	loadimage(&RightImg, "../Hero/RightMove.png");

	//加载怪物向上移动素材
	loadimage(&MonsterUpImg, "../Monster/UpMove.png");


	//加载怪物向下移动素材
	loadimage(&MonsterDownImg, "../Monster/DownMove.png");


	//加载怪物向右移动素材
	loadimage(&MonsterRightImg, "../Monster/RightMove.png");


	//加载怪物向左移动素材
	loadimage(&MonsterLeftImg, "../Monster\\LeftMove.png");


	//生成   生成一个数据库(数组)
	ranking[10000] = {};


	//页面索引
	PersonIndex = 1;

	num_ranking = 1000;


	//加载背景图片
	loadimage(&BgImg, "../Other\\Bg\\Bg.png");

	//加载菜单图片
	loadimage(&TitleImg, "../Other/Bg/Titled_Fields.jpg");


	//加载设置图标
	loadimage(&SetImg, "../Other\\Set\\Set.png");


	//加载排行榜图标
	loadimage(&RankImg, "../Other\\Rank\\Rank.png");

	//加载音量加图标
	loadimage(&SoundOnImg, "../Other/Set/SoundOn.png");

	//加载音量减图标
	loadimage(&SoundOffImg, "../Other/Set/SoundOff.png");


	//游戏  -> 暂停  ->  设置这条路径不存在

	GAME_PAUSE_SET = false;


	//菜单  -> 设置这条路径不存在

	MENU_SET = false;

	//加载数据
	OpeFile();

	imgX = getwidth() / 2;//图片x坐标
	imgY = getheight() / 2;//图片y坐标


	BUTTON_WIDTH = 300;	// 按钮宽度
	BUTTON_HEIGHT = 70;	// 按钮高度
	BUTTON_SPACING = 30;

	BUTTON_X = 800 / 2 - BUTTON_WIDTH / 2;
	BUTTON_Y_1 = 600 / 2 - (BUTTON_HEIGHT * 3 + BUTTON_SPACING * 2) / 2;
	BUTTON_Y_2 = BUTTON_Y_1 + BUTTON_HEIGHT + BUTTON_SPACING;
	BUTTON_Y_3 = BUTTON_Y_2 + BUTTON_HEIGHT + BUTTON_SPACING;


	TEXT_COLOR = BLACK;
	BUTTON_COLOR = WHITE;

	ControlValOne = 0;


	ControlAttack1 = 0;
	ControlAttack2 = 0;
	ControlAttack3 = 0;
	ControlAttack4 = 0;

	FlushMillisecond = 0;


	rx1 = getwidth() / 4 - 29;
	ry1 = getheight() / 4 - 29;
	rx_w1 = getwidth() / 4 + 28;
	ry_h1 = getheight() / 4 + 28;


	rx2 = getwidth() * 3 / 4 - 29;
	ry2 = getheight() / 4 - 29;
	rx_w2 = getwidth() * 3 / 4 + 28;
	ry_h2 = getheight() / 4 + 28;


	x_ = 320;
	y_ = 240;
	w = 160;
	h = 30;


	hSpace = (w - textwidth(_T("开始游戏"))) / 2;
	vSpace = (h - textheight(_T("开始游戏"))) / 2;

	//初始化排行榜
	static int i = 1;
	while (i++ <= num_ranking) {
		ranking[i] = num_ranking * 2 - i;
	}

}